export const storageMinxis = {
  data () {
    return {
      show: true
    }
  },
  methods: {
    setItem (key, value) {
      // 要先判断value是不是对象,是对象要转换成JSON格式
      if (Object.prototype.toString.call(value) === '[object Object]') {
        value = JSON.stringify(value)
      } else if (typeof (value) === 'object') {
        value = JSON.stringify(value)
      }
      localStorage.setItem(key, value)
    },
    getItem (key) {
      const value = JSON.parse(localStorage.getItem(key))
      if (Object.prototype.toString.call(value) === '[object Object]') {
        console.log(232)
        return JSON.parse(localStorage.getItem(key))
      } else if (typeof (value) === 'object') {
        return JSON.parse(localStorage.getItem(key))
      }
      return localStorage.getItem(key)
    },
    removeItem (key) {
      localStorage.removeItem(key)
    }
  }
}
